﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SX.Utils.Log.log4net;
using Topshelf;

namespace Ly.Scheduler.NewService
{
    static class Program
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(Program));
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>

        static void Main()
        {

            Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(AppConfig.ServiceDescription);
                x.SetDisplayName(AppConfig.ServiceDisplayName);
                x.SetServiceName(AppConfig.ServiceName);

                x.Service(factory =>
                {
                    logger.Debug("Creating new instance of server type 'QuartzServer'");
                    QuartzServer server = new QuartzServer();
                    server.Initialize();
                    return server;
                });
            });
        }
    }
}
